<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>thymeleaf</title>
</head>
<body>
<h1 th:text="${msg}">xxx</h1>
<h1 th:text="'您好'+${user.name}">王222</h1>
<h1 th:text="|您好，${user.name}|">王333</h1>
<h1 th:text="${user.age}+10"></h1>

<h1 th:text="${user.age} > 10 ? '是':'否'"></h1>

<!-- 默认值：注意`?:`之间没有空格 -->
<h1 th:text="${user.name} ?: '刘德华'"></h1>

<div th:object="${user}">
    <span th:text="*{name}"></span>
    <span th:text="*{age}"></span>
    <span th:text="*{friend.name}"></span>
</div>

<hr> <!--横线-->
<div th:with="age = ${user.age} + 10">
    <span th:text="${age}"></span>
</div>

<hr>
<table>
    <tbody>
    <!--even/odd，返回是否为奇偶，boolean值-->
    <tr th:each="user,state : ${users}" th:if="${user.age > 22}"  th:style="${state.odd}? 'background-color: red' : 'background-color: green'">
        <td th:text="${state.index} + 1">1</td>
        <td th:text="${user.age}">18</td>
        <td th:text="${user.name}">刘焉</td>
    </tr>
    </tbody>

</table>

<hr>
<div th:switch="${user.age}">
    <span th:case="20">小鲜肉</span>
    <span th:case="30">有为青年</span>
    <span th:case="40">中年大叔</span>
    <span th:case="50">老腊肉</span>
    <span th:case="*">未知</span>
</div>

<hr>
<a th:href="|http://api.gmall.com/pms/brand/${brandId}|">点我呀</a>
<br>
<a th:href="@{http://api.gmall.com/pms/brand/{id}(id=${brandId})}">快点我呀</a>
<br>
<a th:href="@{http://api.gmall.com/pms/brand(pageNum=${pageNum},pageSize=${pageSize})}">快来点我呀</a>

<hr>
<h1 th:text="${user.name.split('')[0]}"></h1>

<hr>
<h1 th:text="${#strings.equals(msg,'hello')}"></h1>
<h1 th:text="${#strings.indexOf(msg,'hello')} >= 0"></h1>
<!--前包含后不包含-->
<h1 th:text="${#strings.substring(msg,6,8)}"></h1>
<h1 th:text="${#strings.replace(msg,'--t','++t')}"></h1>

<h1 th:text="${#numbers.formatDecimal(user.age,1,2)}"></h1>

<h1 th:text="${#lists.isEmpty(users)}"></h1>
<h1 th:text="${#lists.contains(ss,'d')}"></h1>
<h1 th:text="${#dates.format(date,'yyyy-dd-MM')}"></h1>

<hr>
<script th:inline="javascript">
    var user =[[${user}]]
</script>

<hr>
<!--定义通用片段-->
<div th:include="common::header"></div>
<div th:replace="common::header"></div>
<div th:insert="common::header"></div>

</body>
</html>